package com.atguigu.lease.common.minio;

import io.minio.MinioClient;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * ClassName  MinioConfiguration
 * Author  XiaojianOne
 * Date  2025/2/26 20:01
 * Version  8.0
 */

@ConfigurationPropertiesScan("com.atguigu.lease.common.minio")
//@EnableConfigurationProperties(MinioProperties.class)
@Configuration
@ConditionalOnProperty(name = "minio.endpoint")
public class MinioConfiguration {

    @Autowired
    private MinioProperties minioProperties;

    @Bean
    public MinioClient minioClient(){

        return MinioClient.builder().endpoint(minioProperties.getEndpoint()).
                credentials(minioProperties.getAccessKey(),
                        minioProperties.getAccessKey()).build();

    }
}
